﻿/*----------------------------------------------------------------
//  <copyright file="DingTalkExtensions.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2023-09-25 17:17</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud
{
    #region "钉钉身份认证扩展方法"
    /// <summary>
    /// 钉钉身份认证扩展方法
    /// </summary>
    public static class DingTalkExtensions
    {
        #region "扩展方法"
        #region "添加钉钉身份认证"
        /// <summary>
        /// 添加钉钉身份认证
        /// </summary>
        /// <param name="builder">身份认证构建器</param>
        /// <returns>身份认证构建器</returns>
        public static AuthenticationBuilder AddDingTalk(this AuthenticationBuilder builder)
            => builder.AddDingTalk(DingTalkDefaults.AuthenticationScheme,
                _ =>
                { });
        #endregion
        #region "添加钉钉身份认证"
        /// <summary>
        /// 添加钉钉身份认证
        /// </summary>
        /// <param name="builder">身份认证构建器</param>
        /// <param name="configureOptions">钉钉身份认证选项</param>
        /// <returns>身份认证构建器</returns>
        public static AuthenticationBuilder AddDingTalk(this AuthenticationBuilder builder, Action<DingTalkOptions> configureOptions)
            => builder.AddDingTalk(DingTalkDefaults.AuthenticationScheme, configureOptions);
        #endregion
        #region "添加钉钉身份认证"
        /// <summary>
        /// 添加钉钉身份认证
        /// </summary>
        /// <param name="builder">身份认证构建器</param>
        /// <param name="authenticationScheme">钉钉身份认证标识</param>
        /// <param name="configureOptions">钉钉身份认证选项</param>
        /// <returns>身份认证构建器</returns>
        public static AuthenticationBuilder AddDingTalk(this AuthenticationBuilder builder, string authenticationScheme, Action<DingTalkOptions> configureOptions)
            => builder.AddDingTalk(authenticationScheme, DingTalkDefaults.DisplayName, configureOptions);
        #endregion
        #region "添加钉钉身份认证"
        /// <summary>
        /// 添加钉钉身份认证
        /// </summary>
        /// <param name="builder">身份认证构建器</param>
        /// <param name="authenticationScheme">钉钉身份认证标识</param>
        /// <param name="displayName">钉钉身份认证显示名称</param>
        /// <param name="configureOptions">钉钉身份认证选项</param>
        /// <returns>身份认证构建器</returns>
        public static AuthenticationBuilder AddDingTalk(this AuthenticationBuilder builder,
            string authenticationScheme,
            string displayName,
            Action<DingTalkOptions> configureOptions)
            => builder.AddOAuth<DingTalkOptions, DingTalkHandler>(authenticationScheme, displayName, configureOptions);
        #endregion

        #endregion

    }
    #endregion

}
